#!/bin/bash

echo "========================================"
echo "酒店管理系统Maven项目验证脚本"
echo "========================================"
echo

echo "1. 检查项目结构..."
if [ -f "pom.xml" ]; then
    echo "[✓] pom.xml 文件存在"
else
    echo "[✗] pom.xml 文件不存在"
    exit 1
fi

if [ -d "src/main/java" ]; then
    echo "[✓] src/main/java 目录存在"
else
    echo "[✗] src/main/java 目录不存在"
    exit 1
fi

if [ -d "src/main/resources" ]; then
    echo "[✓] src/main/resources 目录存在"
else
    echo "[✗] src/main/resources 目录不存在"
    exit 1
fi

if [ -d "src/test/java" ]; then
    echo "[✓] src/test/java 目录存在"
else
    echo "[✗] src/test/java 目录不存在"
    exit 1
fi

echo
echo "2. 检查主要文件..."
if [ -f "src/main/java/com/hotel/management/HotelManagementApplication.java" ]; then
    echo "[✓] 主启动类存在"
else
    echo "[✗] 主启动类不存在"
    exit 1
fi

if [ -f "src/main/resources/application.yml" ]; then
    echo "[✓] 配置文件存在"
else
    echo "[✗] 配置文件不存在"
    exit 1
fi

echo
echo "3. 检查Java版本..."
if command -v java &> /dev/null; then
    echo "[✓] Java环境正常"
    java -version
else
    echo "[✗] Java环境异常"
    exit 1
fi

echo
echo "4. 检查Maven环境..."
if command -v mvn &> /dev/null; then
    echo "[✓] Maven环境正常"
    mvn -version
else
    echo "[✗] Maven环境异常，请安装Maven"
    exit 1
fi

echo
echo "5. 验证Maven项目..."
echo "正在验证Maven项目结构..."
if mvn validate; then
    echo "[✓] Maven项目验证成功"
else
    echo "[✗] Maven项目验证失败"
    exit 1
fi

echo
echo "6. 编译项目..."
echo "正在编译项目..."
if mvn clean compile -q; then
    echo "[✓] 项目编译成功"
else
    echo "[✗] 项目编译失败"
    exit 1
fi

echo
echo "========================================"
echo "项目验证完成！所有检查都通过了。"
echo "========================================"
echo
echo "下一步操作："
echo "1. 运行项目: mvn spring-boot:run"
echo "2. 访问地址: http://localhost:8080/api/health"
echo "3. 查看文档: README.md"
echo
